package com.sanery.servlet;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sanery.entity.Wrong;

@WebServlet("/detail")
public class DetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Integer wrong_id = Integer.parseInt(request.getParameter("wrong_id"));
		ServletContext application = request.getServletContext();
		Wrong wrong_detail = ((Map<Integer, Wrong>) application.getAttribute("allList")).get(wrong_id);
		request.setAttribute("wrong_detail", wrong_detail);
		request.getRequestDispatcher("/WEB-INF/pages/detail.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
